import random

# def map_with_previous(f, prev, iterable):
#     for v in iterable:
#         yield f(prev, v)
#         prev = v

def map_with_previous_result(f, prev, iterable):
    for v in iterable:
        r = f(prev, v)
        prev = r
        yield r

# map_with_previous(lambda x, y: x + random.choice(["'", "''", "'''"]), ["c", "cs", "d", "ds", "e", "f", "fs", "g", "gs", "a", "as", "b"], "hello")

def example():
    import random
    prev = "hello"
    res = []
    for v in ["c", "cs", "d", "ds", "e", "f", "fs", "g", "gs", "a", "as", "b"]:
        res.append((lambda x, y: x + "|" + y + random.choice(["'", "''", "'''"]))(prev, v))
        prev = v
    return res

def example_two(f, iterable, prev):
    for v in iterable:
    # for v in ["c", "cs", "d", "ds", "e", "f", "fs", "g", "gs", "a", "as", "b"]:
        yield f(prev, v)
        prev = v

# (lambda x, y: x + "|" + y + random.choice(["'", "''", "'''"]))






